home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 8767 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.5 KB

  1. Path: lrz-muenchen.de!news
  2. From: watzka@stat.uni-muenchen.de (Kurt Watzka)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: HELP on string functions ????
  5. Date: 6 Mar 1996 09:42:41 GMT
  6. Organization: Leibniz-Rechenzentrum, Muenchen (Germany)
  7. Distribution: world
  8. Message-ID: <4hjmmh$gjm@sparcserver.lrz-muenchen.de>
  9. References: <313DEA73.7505@msmail.st.stems.com>
  10. NNTP-Posting-Host: sun2.lrz-muenchen.de
  11.  
  12. kim hai <Kim_Hai.Ng@msmail.st.stems.com> writes:
  13.  
  14. >Please help me.
  15.  
  16. >Can anybody tell me if there is similar function in place of "strset()" ?
  17.  
  18. This depends on what "strset()" is supposed to do. There is no
  19. function called strset() in the standard C library. There is
  20. a function called "strset()" in the library that comes with 
  21. a popular compiler for DOS. Since this function is  not very
  22. useful, there might be a reason not to include it in a library.
  23.  
  24. >Or is there another way of doing this :
  25. >I need to reinitialize a char pointer during run-time. The statement 
  26. >char *p; p = ""; is causing me problems.
  27.  
  28. What kind of problems?
  29.  
  30. >I can't use "strset(p,'\0')" 
  31. >because the compiler on the unix machine doesn't recognise the function.
  32.  
  33. As far a C strings are concerned, what exactly would you loose by
  34. writing "*p = 0;". You get an empty string in both cases. If "p" points
  35. to a string constant, _both_ methods should be avoided. If "p" points
  36. to a string that can be modified, "*p = '\0';" clears the string as
  37. far as C string handling is concerned.
  38.  
  39. Kurt
  40. --
  41. | Kurt Watzka                             Phone : +49-89-2180-6254
  42. | watzka@stat.uni-muenchen.de
  43. | ua302aa@sunmail.lrz-muenchen.de
  44.